let word = ['红','绿','蓝','黑','黄'];
let wordcolorArr = ['red','green','blue','black','yellow'];

let color = document.querySelectorAll('.color');
let h1 = document.querySelector('h1');

let restGame = function(){
//"大"的字颜色
let index = randNum(0,4);
h1.innerText = word[index];
let colorIndex = randNum(0,4);
h1.style.color = wordcolorArr[colorIndex]

//"小"的字颜色
//定义一个空数组，用来打乱顺序的文字
let smallArr = [];
let smallColorArr =[];
while(smallArr.length<5){
    let index =randNum(0,4);
    let indexword =word[index];
    if(smallArr.indexOf(indexword) == -1){
        smallArr.push(indexword);
    }
}
while(smallColorArr.length<5){
    let colorIndex =randNum(0,4);
    let colorIndexword =wordcolorArr[colorIndex];
    if(smallColorArr.indexOf(colorIndexword) ==-1){
        smallColorArr.push(colorIndexword);
    }
}
for(let j = 0;j < 5; j++){
    color[j].innerHTML = smallArr[j];
    color[j].style.color = smallColorArr[j];
}
console.log(smallArr,smallColorArr);
};

restGame();